package logic

import (
	"context"
	"gitee.com/A1001574000/feedback-rpc/model"

	"gitee.com/A1001574000/feedback-rpc/feedback"
	"gitee.com/A1001574000/feedback-rpc/internal/svc"

	"github.com/zeromicro/go-zero/core/logx"
)

type UserFeedbackByIDLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewUserFeedbackByIDLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UserFeedbackByIDLogic {
	return &UserFeedbackByIDLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *UserFeedbackByIDLogic) UserFeedbackByID(in *feedback.UserFeedbackByIDRequest) (*feedback.UserFeedbackByIDResponse, error) {
	m := new(model.Feedback)
	feedbackInfo, err := m.Select(int(in.UserID))
	if err != nil {
		return nil, err
	}
	return &feedback.UserFeedbackByIDResponse{
		UserFeedback: &feedback.UserFeedback{
			Id:           int64(feedbackInfo.ID),
			UserId:       feedbackInfo.UserId,
			FeedbackText: feedbackInfo.FeedbackText,
			FeedbackType: feedbackInfo.FeedbackType,
			ContactWay:   feedbackInfo.ContactWay,
		},
	}, nil
}
